<?php


namespace app\suguan\controller;


use app\suguan\utils\User as AdminUser;

class Admin extends Base
{
    public function index()
    {
        $uid = AdminUser::getUid();
        $userInfo = model('Admin')->getUserInfo($uid);
        $house_id = $this->house_id();
        $userInfo['house'] = model('House')->where('id',$house_id)->value('title');
        return $this->ok($userInfo);
    }

    public function save()
    {
        $params = request()->only(['user_name', 'user_password', 'realname']);
        $params['uid'] = AdminUser::getUid();
        try {
            model('Admin')->saveData($params);
        } catch (\Exception $e) {
            return $this->fail($e->getMessage());
        }
        return $this->ok('修改成功');
    }
}